﻿using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
namespace Moonlite.ExtensionApi {
    public class HybridCollection<T> : KeyedCollection<T, T> {
        public void AddRange(IEnumerable<T> items) {
            if (items == null) {
                throw new ArgumentNullException("items");
            }
            foreach (T item in items) {
                Add(item);
            }
        }
        protected override T GetKeyForItem(T item) {
            return item;
        }
        public void UniqueAddRange(IEnumerable<T> items) {
            if (items == null) {
                throw new ArgumentNullException("items");
            }
            foreach (T item in items) {
                if (!Contains(item)) {
                    Add(item);
                }
            }
        }
        public HybridCollection() {
        }
        public HybridCollection(IEqualityComparer<T> comparer, int dictionaryCreationTreshold)
            : base(comparer, dictionaryCreationTreshold) {
        }
        public HybridCollection(IEqualityComparer<T> comparer)
            : base(comparer) {
        }
        public HybridCollection(IEnumerable<T> items, IEqualityComparer<T> comparer)
            : base(comparer) {
            if (items != null) {
                AddRange(items);
            }
        }
    }
}
